<template>
  <j-modal
    :title='title'
    :width='width'
    :visible='visible'
    switchFullscreen
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel='handleCancel'
    @ok='handleCancel'
    cancelText='关闭'>
    <template>
      <a-table
        ref='table'
        size='middle'
        :scroll='{x:1175,y:600}'
        bordered
        :rowKey='(record,index)=>{return index}'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='false'
        :loading='loading'
        class='j-table-force-nowrap'>
        <template slot='todayWork' slot-scope='text'>
          <j-ellipsis :value='text' :length='10' />
        </template>
        <template slot='nextDayWork' slot-scope='text'>
          <j-ellipsis :value='text' :length='10' />
        </template>
        <template slot='goodsName' slot-scope='text'>
          <j-ellipsis :value='text' :length='10' />
        </template>
      </a-table>
    </template>


  </j-modal>
</template>


<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { filterDictTextByCache } from '@comp/dict/JDictSelectUtil'
import { sorter } from '@/utils/sorter'

export default {
  name: 'HfPmProjectDetailsModal',
  mixins: [JeecgListMixin],
  data() {
    return {
      title: '明细',
      width: '90%',
      type: '',
      activeKey: 1,
      visible: false,
      disableSubmit: true,
      columns: [],
      tabsData: [],
      disableMixinCreated: true,
      url: {}
    }
  },
  methods: {
    handleCancel() {
      this.visible = false
    },
    handleTabsChange(key) {
      this.activeKey = key
    },
    show(result, field) {
      if (field === 'purchase') {
        this.visible = true
        this.columns = []
        this.dataSource = result
        this.columns.push(
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '合同编号',
            align: 'center',
            dataIndex: 'num',
            sorter: true,
          },
          {
            title: '合同名称',
            align: 'center',
            dataIndex: 'name',
          },
          {
            title: '客户简称',
            align: 'center',
            dataIndex: 'customerName',
          },
          {
            title: '合同金额',
            align: 'right',
            dataIndex: 'money',
            customRender: (text) => {
              return !text ? '0' : String(text.toFixed(2)).replace(/\B(?=(\d{3})+(?!\d))/g, ',')
            },
          },
          {
            title: '供应商名称',
            align: 'center',
            dataIndex: 'supplierName',
          },
          {
            title: '签订日期',
            align: 'center',
            dataIndex: 'signDate',
            customRender: function (text) {
              return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
            },
          },
        )
      }
      if (field === 'exploitWorkday'||field === 'implementWorkday') {
        this.visible = true
        this.columns = []
        this.dataSource = result
        this.columns.push(
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '姓名',
            align:"center",
            dataIndex: 'reportPersion'
          },
          {
            title: '项目阶段',
            align:"center",
            dataIndex: 'projectPhase',
            customRender: (t) => {
              return filterDictTextByCache('project_phase', t) || '--'
            }
          },
          {
            title: '今日完成',
            align:"center",
            dataIndex: 'todayWork',
            scopedSlots: { customRender: 'todayWork' }
          },
          {
            title: '明日计划',
            align:"center",
            dataIndex: 'nextDayWork',
            scopedSlots: { customRender: 'nextDayWork' }
          },
          {
            title: '填报时间',
            align:"center",
            dataIndex: 'writeTime',

          }
        )
      }
      if (field === 'humanCost') {
        this.visible = true
        this.columns = []
        this.dataSource = result
        this.columns.push(
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '填报人',
            align:"center",
            dataIndex: 'reprotPersion'
          },
          {
            title: '人天单价',
            align:"center",
            dataIndex: 'meanValue'
          },
          {
            title: ' 天数',
            align:"center",
            dataIndex: 'countNum'
          },
          {
            title: '总计',
            align:"center",
            dataIndex: 'addUp'
          },
        )
      }
      if (field === 'reimbursementMoney'||field === 'saleReimbursementMoney') {
        this.visible = true
        this.columns = []
        this.dataSource = result
        this.columns.push(
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '日期',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title: '报销编号',
            align:"center",
            dataIndex: 'code'
          },
          {
            title: '姓名',
            align:"center",
            dataIndex: 'createBy'
          },
          {
            title: '报销类型',
            align:"center",
            dataIndex: 'type',
            customRender: (t) => {
              return filterDictTextByCache('hf_oa_reimbursement_type', t) || '--'
            }
          },
          {
            title: '金额(元)',
            align:"center",
            dataIndex: 'total'
          },

        )
      }
      if (field === 'judge'||field === 'purchaseB') {
        this.visible = true
        this.columns = []
        this.dataSource = result
        this.columns.push(
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '日期',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title: '编号',
            align:"center",
            dataIndex: 'num'
          },
          {
            title: '姓名',
            align:"center",
            dataIndex: 'createBy'
          },
          {
            title: ' 采购名称',
            align:"center",
            dataIndex: 'purchaseName'
          },
          {
            title: '类别',
            align:"center",
            dataIndex: 'costType',
            customRender: (t) => {
              return filterDictTextByCache('cost_type', t) || '--'
            }
          },

          {
            title: '数量',
            align:"center",
            dataIndex: 'count'
          },
          {
            title: '金额',
            align:"center",
            dataIndex: 'money'
          }
        )
      }
      if (field === 'travel') {
        this.visible = true
        this.columns = []
        this.dataSource = result
        this.columns.push(
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '姓名',
            align:"center",
            dataIndex: 'name'
          },
          {
            title: '出差目的地',
            align:"center",
            dataIndex: 'travelBourn'
          },
          {
            title: '合计天数',
            align:"center",
            dataIndex: 'countDayB'
          },
          {
            title: '差补金额(元)',
            align:"center",
            dataIndex: 'travelPiece'
          },
        )
      }
      if (field === 'bingingMoney') {
        this.visible = true
        this.columns = []
        this.dataSource = result
        this.columns.push(
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          // {
          //   title: '销售经理',
          //   align:"center",
          //   dataIndex: 'projectCharger'
          // },
          // {
          //   title: '规格型号',
          //   align:"center",
          //   dataIndex: 'model'
          // },
          {
            title: '中标服务费',
            align:"center",
            dataIndex: 'biddingMoney'
          },
          {
            title: '付款日期',
            align:"center",
            dataIndex: 'issueTime'
          }
        )
      }
      if (field === 'taxesMoney') {
        this.visible = true
        this.columns = []
        this.dataSource = result
        this.columns.push(
          {
            title: '#',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function(t, r, index) {
              return parseInt(index) + 1
            }
          },
          {
            title: '项目名称',
            align:"center",
            dataIndex: 'name'
          },
          {
            title: '税费',
            align:"center",
            dataIndex: 'taxation'
          },
        )
      }

    }
  }

}
</script>
<style lang='less' scoped>
/deep/ .ant-modal {
  top: 60px;
}

</style>